package com.lmm.consumer.controller;

import com.lmm.api.HelloWorldService;
import com.lmm.rpc.client.annotation.RpcAutowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @title: HelloWorldController
 * @Description: TODO
 * @Author Lmm
 * @Date: 2022/10/9 15:30
 * @Version 1.0
 */
@RestController
public class HelloWorldController {
    private static final long count = 100000;
    @RpcAutowired
    private HelloWorldService helloWorldService;

    @GetMapping("/hello/world")
    public void sayHello(){

        int i = 0;
        long start = System.currentTimeMillis();
//        int i1 = Runtime.getRuntime().availableProcessors();
//        System.out.println(i1);
        while (i++ < count){
            helloWorldService.hello("lmm"+i);
        }
        long end = System.currentTimeMillis();
        long time = (end - start) / 1000;
        System.out.println("total request:"+count);
        System.out.println("spend total time:"+time+" s");
    }

}
